package com.itheima.d5_synchronized_method;

/**
 * 目标：模拟线程安全问题。
 */
public class ThreadTest {
    public static void main(String[] args) {
        Account account = new Account("ICBC-666", 100000);

        // 任务类对象
        DrawThread drawThread = new DrawThread(account);

        new Thread(drawThread, "小明").start();
        new Thread(drawThread, "小红").start();
    }
}


// 任务类
class DrawThread implements Runnable {
    private Account account;

    public DrawThread() {
    }

    public DrawThread(Account account) {
        this.account = account;
    }


    @Override
    public void run() {
        try {
            account.drawMoney(100000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
